<template>
  <div class="search">
    <f-form ref="form" :action="api.shop" :form-key="this.formItem.shopId" >
      <f-form-item label="商家名称"  name="shopName" dataType="${formField.dataType}"   :value="formItem.shopName" />
      <f-form-item label="商家图片"  name="shopImg" dataType="${formField.dataType}"   :value="formItem.shopImg" />
      <f-form-item label="商家描述"  name="shopDesc" dataType="${formField.dataType}"   :value="formItem.shopDesc" />
      <f-form-item label="员工所属机场（不必要）"  name="airportId" dataType="${formField.dataType}"   :value="formItem.airportId" />
      <f-form-item label="营业时间"  name="shopTime" dataType="${formField.dataType}"   :value="formItem.shopTime" />
      <f-form-item label="机场地址"  name="shopAddress" dataType="${formField.dataType}"   :value="formItem.shopAddress" />
      <f-form-item label="门店电话"  name="shopPhone" dataType="${formField.dataType}"   :value="formItem.shopPhone" />
      <f-form-item label="商家类型"  name="shopCategoryId" dataType="${formField.dataType}"   :value="formItem.shopCategoryId" />
      <f-form-item label="是否上架（2不上架，1上架）"  name="isShelf" dataType="number"   :value="formItem.isShelf" />
      <f-form-item label="排序"  name="shopSort" dataType="number"   :value="formItem.shopSort" />
      <f-form-item label="创建日期"  name="createDate" dataType="${formField.dataType}"   :value="formItem.createDate" />
    </f-form>
  </div>
</template>
<script>
  import api from './js/api'
  export default {
    name: 'shopForm',
    props: {},
    data() {
      return {
        refs:this.$refs,
        api:  Object.assign(api, this.api),
        isAdd: true,//是否是添加模式
        loaded: false,//是否加载完成
        formItem: this.getFormItem()
      }
    },
    methods: {
      getFormItem() {
        return {
          shopId: '',
          shopName: '',
          shopImg: '',
          shopDesc: '',
          airportId: '',
          shopTime: '',
          shopAddress: '',
          shopPhone: '',
          shopCategoryId: '',
          isShelf: '',
          shopSort: '',
          createDate: ''
        }
      },
      //表单赋值
      setData(data) {
        this.$refs.form.resetFields()
        this.formItem = this.getFormItem()
        if (data && data.shopId) {
          let params={
              shopId:data.shopId
          }
          this.refs['form'].getDetails(params,(data)=>{
             this.formItem=data
             this.loaded = true
          })
          this.isAdd = false
        } else {
          this.loaded = true
        }
      },
      //提交表单
      handleSubmit(callback) {
        this.$refs.form.submit({  }, callback)
      }
    },
    created() {
    },
    components: {}
  }
</script>

<style scoped lang="less" rel="stylesheet/less">

</style>
